//
//  ViewController.m
//  ImageHop
//
//  Created by Justsoso on 16/2/19.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (weak, nonatomic) IBOutlet UIButton *btn;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    NSMutableArray *mArr = [[NSMutableArray alloc] init];
    for (int i=1; i<=20; i++)
    {
        NSString *picName = [NSString stringWithFormat:@"frame-%i.png",i];
        UIImage *image = [UIImage imageNamed:picName];
        [mArr addObject:image];
    }
    self.imageView.animationImages = mArr;
    self.imageView.animationDuration = 2;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)btnPressed:(UIButton *)sender
{
    if (self.imageView.isAnimating)
    {
        [self.imageView stopAnimating];
        [self.btn setTitle:@"跳" forState:UIControlStateNormal];
    }
    else
    {
        [self.imageView startAnimating];
        [self.btn setTitle:@"停" forState:UIControlStateNormal];
    }
}
- (IBAction)sliderChanged:(UISlider *)sender
{
    self.imageView.animationDuration = 2 - sender.value;
    [self.imageView startAnimating];
}

@end
